import { HttpPromise } from '@nutpi/axios';
import { HotTopicResp } from '../bean/HotTopicResp';
import { TopicDetailResp } from '../bean/TopicDetailResp';
import { TopicListResp } from '../bean/TopicListResp';
import { AnswerListResp, QaDetailResp, QAResp, TagData } from '../bean/QAResp';
import { axiosClient } from '../axiosClient';
import { LoginReq, LoginResp, UserData } from '../bean/LoginResp';
import { FavoriteResp } from '../bean/FavoriteResp';
import {WaveHouseParam,WaveHouseResp} from '../bean/WareHouseResp'
import { CourseListReq, CourseListResp } from '../bean/CourseListResp';
import { PublishReq, PublishResp, TagItem, TagResp } from '../bean/PublishBean';
import { JSON } from '@kit.ArkTS';

// 1.获取热门文章api接口
export const getHotTopics = (): HttpPromise<HotTopicResp> => axiosClient.get({url:'/hottopic'});

// 2.获取话题(文章)列表信息接口
export const getTopicList = (page:number): HttpPromise<TopicListResp> => axiosClient.get({url:'/topiclist',params:{page:page}});

// 3.获取话题(文章)详情接口
export const getTopicDetail = (id:number): HttpPromise<TopicDetailResp> => axiosClient.get({url:'/topicdetail',params:{id:id}});

//  获取问答列表接口
export const getQAList = (page:number): HttpPromise<QAResp> => axiosClient.get({url:'/asklist',params:{page:page}});


//  获取问答详情接口
export const getAskDetail = (questionId:string): HttpPromise<QaDetailResp> => axiosClient.get({url:'/askDetail',params:{questionId:questionId}});

//  获取问答详情回复裂变接口
export const getAnswerList = (questionId:string,page:number): HttpPromise<AnswerListResp> => axiosClient.get({url:'/answerList',params:{questionId:questionId,page:page}});


//登录接口
export const postLogin = (loginData:LoginReq): HttpPromise<LoginResp> => axiosClient.post({url:'/userLogin',data:loginData});


//  获取收藏列表接口
export const getFavoriteList = (page:number): HttpPromise<FavoriteResp> => axiosClient.get({url:'/user/favoriteList',params:{page:page}});

//  获取我的文章列表接口
export const getMyTopicList = (page:number): HttpPromise<FavoriteResp> => axiosClient.get({url:'/user/topiclist',params:{page:page}});

//  获取我的回答
export const getMyAnswerList = (page:number): HttpPromise<AnswerListResp> => axiosClient.get({url:'/user/answerList',params:{page:page}});

//  获取我的提问
export const getMyAskList = (page:number): HttpPromise<QAResp> => axiosClient.get({url:'/user/asklist',params:{page:page}});


//  获取我的点赞
export const getMyLikeList = (page:number): HttpPromise<FavoriteResp> => axiosClient.get({url:'/user/likeList',params:{page:page}});


// 获取三方仓库接口
export const getWaveHouseList=(WaveHouseParam:WaveHouseParam):HttpPromise<WaveHouseResp> => axiosClient.get({url:'/ohpm/search',params:WaveHouseParam});


export const getCourseList = (courseReq :CourseListReq) : HttpPromise<CourseListResp> => axiosClient.post({url: "/course/list", data: courseReq })

//发布文章（建议拓展增加发布类型）
export const publishContent = (publishData:PublishReq): HttpPromise<PublishResp> => axiosClient.post({url:'/pubArticle',data:JSON.stringify(publishData)});

//获取所有标签TAG
export const getAllTagList = () : HttpPromise<TagResp> => axiosClient.get({url: "/allTag"})

